//
//  HTSubject.swift
//  MagaCore
//
//  Created by MrMessy on 2023/5/12.
//

import Foundation
import HandyJSON

struct HTSubject: HandyJSON {
  var var_id: String?// 专题id
  var var_name: String?// 专题显示标题
  var var_seeall: String?// 专题右侧seeall按钮是否显示：1显示，0不显示
  var var_info_type_2: String?
  var var_data_type: String?
  var var_animes: [HTAnime]?

  mutating func mapping(mapper: HelpingMapper) {
    mapper <<<
      self.var_id <-- "open_mode_value"

    mapper <<<
      self.var_name <-- "name"

    mapper <<<
      self.var_seeall <-- "seeall"

    mapper <<<
      self.var_info_type_2 <-- "info_type_2"

    mapper <<<
      self.var_data_type <-- "data_type"

    mapper <<<
      self.var_animes <-- "data"
  }

  func ht_Animes() -> [HTAnime]? {
    if (self.var_info_type_2 == "ztype") {
      return (self.var_animes?[0] as? HTAnime)?.var_a20 ?? []
    }

    return self.var_animes!
  }
}
